package com.tkjt.pms.modules.indexvaluemirror.controller;

import com.tkjt.pms.common.entity.TkIndexValue;
import com.tkjt.pms.common.entity.TkIndexValueMirror;
import com.tkjt.pms.modules.indexvaluemirror.service.IndexValueMirrorService;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/pms/indexvaluemirror")
public class IndexValueMirrorController {

    @Autowired
    private IndexValueMirrorService indexValueMirrorService;
    /**
     * 镜像数据列表
     * @param
     * @return
     */
    @RequestMapping(value = "datagrid")
    public Result<?> datagrid(@RequestBody TkIndexValueMirror tkIndexValueMirror,HttpServletRequest req){
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        if(loginUser==null) {
            return Result.error("用户非法！");
        }
        try {
            return indexValueMirrorService.datagrid(loginUser,tkIndexValueMirror,tkIndexValueMirror.getPageNo(),tkIndexValueMirror.getPageSize(),req);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("获取数据异常");
        }
    }
}
